var rowid=null;
var rowhid=null;
var rowpid=null;
var pageSize = 10;
var scheduIntervalCodeMap = {};
$(document).ready(function(){
	var type=$('#tId').val();
	var pId=$('#pId').val();
	commonSet();
	//表格初始化
	initTable();
	//事件绑定
	eventBind(pId);
	pageQuery();
});

function commonSet(){
	scheduIntervalCodeMap=getTransParam('scheduIntervalCode');
}

function eventBind(pId){
	//带有分页信息的查询
	$("#queryBtn").click(pageQuery).click();
	//退号
	$("#resonBtn").click('click',function(){
		showRegFormDialog(pId);
	});
}

function initTable(){
	$('#regTable').bootstrapTable({
		onPageChange: function (number, size) {
			pageSize = size;
			queryUn(number, size);
		},
		onCheck:function (row) {
			rowid=row.id;
			rowpid=row.patient_id;
		}
	});
}

//带有分页信息的查询
function pageQuery(){
	query(1, pageSize);
};

//分页查询待接诊
function query(pageNumber, pageSize){
	var queryCondition={
		pageNumber: pageNumber, 
		pageSize: pageSize,
		params:$("#regForm").collect()
	}
	$.getApiClient('/register/list').setQuery(queryCondition).post().done(function(data){
	    $('#regTable').bootstrapTable('load', data.payload);
	});
};
//退号操作
function showRegFormDialog(){
	if(rowid==null){
		customAlertDialog("请选择预约后进行操作", '错误提示', null, null);
	}else{
		customRemoteUrlDialog('退号','/page/business/register/regReson?pId='+rowpid+'&rId='+rowid,null);
	}
}
